<template>
  <div class="block">
    <el-timeline>
      <el-timeline-item
          :timestamp="activity.pushtime"
          placement="top"
          v-for="(activity, index) in activities"
          :key="index"
          color:#0bbd87
      >
        <el-card>
          <h3>{{ activity.author }}</h3>
          <h4>{{ activity.content }}</h4>
          <p></p>
        </el-card>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';
import { ElTimeline, ElTimelineItem, ElCard } from 'element-plus';

// 定义响应式数据
const activities = ref([{
  author: "",
  content: '',
  pushtime: ''
}]);

// 获取数据的函数
const fetchActivities = async () => {
  try {
    const result = await axios.get('/ky/user/oneword');
    activities.value = result.data.data;
  } catch (error) {
    console.error('获取数据出错:', error);
  }
};

// 生命周期钩子，在组件挂载后执行获取数据的操作
onMounted(() => {
  fetchActivities();
});
</script>

<style>
.a {
  color: rgb(74, 74, 182);
}
</style>